/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ipinyou.wordstatistics.core;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author xiangnan.wang@ipinyou.com
 */
public class HandleResult {
    
    private String fileName;
    
    private List<CodeInfo> codeInfoL;
    
    public HandleResult(){
        codeInfoL=new ArrayList<CodeInfo>();
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public List<CodeInfo> getCodeInfoL() {
        return codeInfoL;
    }

    public void addCodeInfo(CodeInfo codeInfo) {
        this.codeInfoL.add(codeInfo);
    }
    
    public void addCodeInfos(List<CodeInfo> codeInfos) {
        this.codeInfoL.addAll(codeInfos);
    }
    
    public boolean isContainCodes(){
        return codeInfoL.size()>0;
    }
    
    public List<CodeInfo> getCodeInfoByLineNum(int lineNum){
        List<CodeInfo> rstL=new ArrayList<CodeInfo>();
        for(CodeInfo ci:codeInfoL){
            if(ci.getLineNum()==lineNum){
                rstL.add(ci);
            }
        }
        return rstL;
    }

    @Override
    public String toString() {
        return "HandleResult{" + "fileName=" + fileName + ", codeInfoL=" + codeInfoL + '}';
    }
    
    public static class CodeInfo{
        
        private String lineCode;
        
        private int lineNum;
        
        private int startIndex;
        
        private int endIndex;
        
        public CodeInfo(){
            
        }
        
        public CodeInfo(String lineCode,int lineNum,int start,int end){
            this.lineCode=lineCode;
            this.lineNum=lineNum;
            this.startIndex=start;
            this.endIndex=end;
        }

        public String getLineCode() {
            return lineCode;
        }

        public void setLineCode(String lineCode) {
            this.lineCode = lineCode;
        }

        public int getLineNum() {
            return lineNum;
        }

        public void setLineNum(int lineNum) {
            this.lineNum = lineNum;
        }

        public int getStartIndex() {
            return startIndex;
        }

        public void setStartIndex(int startIndex) {
            this.startIndex = startIndex;
        }

        public int getEndIndex() {
            return endIndex;
        }

        public void setEndIndex(int endIndex) {
            this.endIndex = endIndex;
        }
        
        @Override
        public String toString() {
            return "codeInfo{" + "lineCode=" + lineCode + ", lineNum=" + lineNum + '}';
        }


        
    }
}


